broadway: Ensure we allocate shm surface space early
authorAlexander Larsson <alexl@redhat.com>
Wed, 3 Apr 2013 13:50:54 +0000 (15:50 +0200)
committerAlexander Larsson <alexl@redhat.com>
Wed, 3 Apr 2013 13:58:42 +0000 (15:58 +0200)
This is nicer then getting random sigbus later

gdk/broadway/gdkbroadway-server.c

index adc28a0b726f46350a8a2539100f88e3c7ec46fa..f5df46a6b4bdbee2119604e6420095888f09f27f 100644 (file)
@@ -582,6 +582,13 @@ _gdk_broadway_server_create_surface (int                 width,
   res = ftruncate (fd, data->data_size);
   g_assert (res != -1);
 
+  res = posix_fallocate (fd, 0, data->data_size);
+  if (res != 0)
+    {
+      shm_unlink (data->name);
+      g_error ("Not enough shared memory for window surface");
+    }
+
   data->data = mmap(0, data->data_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); 
   (void) close(fd);